<!DOCTYPE html> 
<html> 
<head> 
    <!--META-->
    <meta charset="utf-8">
    <meta name="format-detection" content="telephone=no" />
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
    <meta name="msapplication-tap-highlight" content="no" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">

    <!--CSS-->
    <link rel="stylesheet" href="API/css/themes/default/jquery.mobile.min.css" />
    <link rel="stylesheet" href="API/css/mycss.css" />
    <link rel="stylesheet" href="css/mycss.css" />

    <!--JS-->
    <script type="text/javascript" src="include/config.js"></script>
    <script type="text/javascript" src="API/js/jquery.min.js"></script>
    <script type="text/javascript" src="API/js/jquery.mobile.min.js"></script>
    <script type="text/javascript" src="API/js/functionsLib.js"></script>
    <script type="text/javascript" src="js/fonctions.js"></script>

    <script language="javascript" type="text/javascript">
    ///////////////////
    //BLOCK VARIABLE GLOBAL
    ///////////////////
    var id_page = 2;

    ///////////////////
    //BLOCK FONCTIONS EVENEMENTS
    ///////////////////
    //Fin chargement page
    function OnLoad() {
        try {
            var contact_mail_administrateur = $.functionsLib.getParameter("contact_mail_administrateur");
            var nom_site = $.functionsLib.getParameter("nom_site");
            var shtml = '<a href="mailto:'+contact_mail_administrateur+'?subject=[ODA-'+nom_site+']Contact - '+$.functionsLib.getUserInfo().code_user+'">Administrateur</a>.';
            $("#emailAdmin").html(shtml).trigger("create");
        } catch (er) {
            $.functionsLib.log(0, "ERROR(OnLoad):" + er.message);
        }
    }

    ///////////////////
    //BLOCK FONCTIONS METIER
    ///////////////////
    /**
     * saisirContact
     * 
     * @param {type} p_codeDate
     * @param {type} p_reponse
     * @param {type} p_message
     * @returns {undefined}
     */
    function saisirContact(p_codeDate, p_reponse, p_message) {
        try {
            var strDate = $.functionsLib.getStrDateFR();
            if((p_codeDate != "")&&(p_reponse != "")&&(p_message != "")){
                if(strDate == p_codeDate){
                    var contact_mail_administrateur = $.functionsLib.getParameter("contact_mail_administrateur");
                    if(contact_mail_administrateur != ""){
                        var result = insertContact(p_reponse, p_message, $.functionsLib.getUserInfo().code_user);
                        if(result["strErreur"] == ""){
                            var message_html = "";
                            var sujet = "";

                            message_html = "";
                            message_html += "<html><head></head><body>";
                            message_html += "De : <pre>"+$.functionsLib.getUserInfo().code_user+"</pre>";
                            message_html += "</br></br>";
                            message_html += "Contact : <pre>"+p_reponse+"</pre>";
                            message_html += "</br></br>";
                            message_html += "Message : <pre>"+p_message+"</pre>";
                            message_html += "</body></html>";

                            sujet = "[ODA-"+getParameter("nom_site")+"]Nouveau message du "+strDate+".";

                            var paramsMail = {
                                email_mail_ori : contact_mail_administrateur
                                , email_labelle_ori : "Service Mail ODA"
                                , email_mail_reply : contact_mail_administrateur
                                , email_labelle_reply : "Service Mail ODA"
                                , email_mails_dest : contact_mail_administrateur
                                , message_html : message_html
                                , sujet : sujet
                            };

                            var retour = $.functionsLib.sendMail(paramsMail);

                            $("#codeDate").val("");
                            $("#howtocontact").val("");
                            $("#textarea").val("");
                            $("#div_contact").collapsible( "collapse" );

                            $.functionsLib.notification("Demande bien soummise sous l'identifiant n&ordm;"+result["data"]["resultat"]["id"]+".",$.functionsLib.oda_msg_color.SUCCES);
                        }else{
                            $.functionsLib.notification(result["strErreur"],$.functionsLib.oda_msg_color.ERROR);
                        }
                    }else{
                        $.functionsLib.notification("Mail du service non définie.",$.functionsLib.oda_msg_color.ERROR);
                    }
                }else{
                    $.functionsLib.notification("Code de s&eacute;curit&eacute; incorrect.",$.functionsLib.oda_msg_color.WARNING);
                }
            }else{
                $.functionsLib.notification("Merci de saisir chaque champs.",$.functionsLib.oda_msg_color.WARNING);
            }
        } catch (er) {
            $.functionsLib.log(0, "ERROR(saisirContact):" + er.message);
        }
    }
    </script>
</head> 

<body onload="OnLoad();"> 

    <!-- page -->
    <div data-role="page" data-title="Titre">

        <!-- /panel -->
        <div data-role="panel" id="mypanel" data-display="overlay" data-position="left">

        </div>
        <!-- /panel -->

        <!-- header -->
        <div data-role="header">
            <a href="#mypanel" data-role="button" data-icon="home" data-iconpos="notext">home</a>
            <h1 id="id_titre">titre</h1>
        </div>
        <!-- /header -->

        <!-- content -->
        <div data-role="content" id="main_content">
            <div data-role="collapsible" data-collapsed="false" data-mini="true" id="div_coordonnees">
                <h4>Par E-mail</h4>
                <p>Email contact administrateur : <label id="emailAdmin"></label></p>
            </div>

            <div data-role="collapsible" data-collapsed="false" data-mini="true" id="div_contact">
                <h4>Par formulaire de contact</h4>
                <form action="form.php" method="post" name="form_contact" id="form_contact">
                    <div data-role="fieldcontain">
                        <label for="basic">Saisir code de s&eacute;curit&eacute;, la date du jour :</label><br>
                        <input type="text" name="codeDate" id="codeDate" value="" placeholder="dd/mm/yyyyy"/>
                    </div>
                    <div data-role="fieldcontain">
                        <label for="basic">Comment vous r&eacute;pondre (Gsm, Email, etc) :</label><br>
                        <input type="text" name="howtocontact" id="howtocontact" value="" placeholder="R&eacute;ponse ici"/>
                    </div>	
                    <div data-role="fieldcontain">
                        <label for="textarea">Votre message :</label><br>
                        <textarea name="textarea" id="textarea">
                        </textarea>
                    </div>	
                    <a href="javascript:saisirContact(document.forms.form_contact.codeDate.value, document.forms.form_contact.howtocontact.value, document.forms.form_contact.textarea.value);" data-role="button" data-inline="true" data-icon="arrow-r" data-mini="true">Soumettre</a>					
                </form>
            </div>
        </div>
        <!-- /content -->

        <!-- footer -->
        <div data-role="footer" data-position="fixed">
            <a data-role="button" data-icon="search" data-iconpos="notext" class="ui-btn-left" href="javascript:window.location = ('./api_page_faq.html?mili='+$.functionsLib.getMilise());">FAQ</a>
            <h1 id="id_affichageUser">User</h1>
            <a data-role="button" data-icon="delete" data-iconpos="notext" class="ui-btn-right" href="javascript:window.location = ('./api_page_sortie.html?mili='+$.functionsLib.getMilise());">Logout</a>
        </div>
        <!-- /footer -->

    </div>
    <!-- /page -->
	
</body>
</html>

